package net.zabuchy.project.bo;
 
import java.util.List;
 
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
 
import net.zabuchy.project.dao.ProjectDao;
import net.zabuchy.project.entity.Project;
 
@Transactional
public class ProjectBoImpl implements ProjectBo {
 
    private static final Logger LOGGER = Logger.getLogger(ProjectBoImpl.class.getName());
 
    @Autowired
    private ProjectDao projectDao;
 
   
    public ProjectDao getProjectDao() {
		return projectDao;
	}

	public void setProjectDao(ProjectDao projectDao) {
		this.projectDao = projectDao;
	}

	public void add(Project project) {
        if (project == null) {
            return;
        }
        LOGGER.debug("Adding the following project: " + project.getTitle() + ", " + project.getDescription());
        projectDao.add(project);
    }
 
    public void delete(Project project) {
        if (project == null) {
            return;
        }
        LOGGER.debug("Deleteting the following project: " + project.getTitle() + ", " + project.getDescription());
        projectDao.delete(project);
    }
    
    public void edit(Project project) {
    	LOGGER.debug("Updating the following project: " + project.getTitle() + ", " + project.getDescription());
    	projectDao.update(project);
    }
    
 
    public List findAll() {
        LOGGER.debug("Getting all projects");
        return projectDao.findAll();
    }
 
    public Project findById(int id) {
        return projectDao.findById(id);
    }
 
    public Project findByTitle(String title) {
        return projectDao.findByTitle(title);
    }
 
    public void update(Project project) {
        if (project == null) {
            return;
        }
        projectDao.update(project);
    }
}